﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace Simple_Draw_Lab
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            KeyUp += MainWindow_KeyUp;
            
            //Start timer
            var timer = new DispatcherTimer();
            timer.Tick += clock_Tick;
            timer.Start();
        }

        void clock_Tick(object sender, EventArgs e)
        {
            clock.Content = sender.ToString();
        }

        void MainWindow_KeyUp(object sender, KeyEventArgs e)
        {
            SolidColorBrush color;
            switch (e.Key)
            {
                case Key.B:
                    color = Brushes.Black;
                    break;
                case Key.R:
                    color = Brushes.Red;
                    break;
                case Key.Y:
                    color = Brushes.Yellow;
                    break;
                default:
                    color = (SolidColorBrush) drawColor.Fill;
                    break;
            }
            drawColor.Stroke = drawColor.Fill = color;
        }

        private void canvas1_MouseMove(object sender, MouseEventArgs e)
        {
            Point position = e.GetPosition(null);
            xpos.Text = position.X.ToString();
            ypos.Text = position.Y.ToString();
        }
    }
}
